

import {  computed } from "vue";
import { storeToRefs } from "pinia";
import pinia from "@/store/index";
import { User } from "@/store/user"
import { Page } from "@/store/page";
import { joinURL } from '@/utils/publicMethods'

export const { appHeight, roleInfo,VIPinfo,info,hasLogin }:any = storeToRefs(User(pinia));
export const { adminI18n, lang, settings,serviceUrlObj }:any  = storeToRefs(Page(pinia));
export const userStore = User()

// 是否登录
 export const isLocalLoggedIn = computed(()=>userStore.isLocalLoggedIn) 




// 用户头像
export const avatarUrl: any = computed(() => {
  if (!userStore.isLocalLoggedIn) return "/imgs/head_icons/default.webp";
  if (!roleInfo.value.head_photo) return `/imgs/head_icons/1002.webp`;
  if (roleInfo.value.head_photo.toString().includes(".")) {
    return joinURL(settings.value.media_url, roleInfo.value.head_photo);
  } else {
    if (
      ![1000, 1001, 1002, 1003, 1004, 1005, 1006, 2001, 2002, 2003, 2004, 2005, 2006].includes(
        Number(roleInfo.value.head_photo)
      )
    ) {
      return `/imgs/head_icons/1002.webp`;
    }
  }
  return `/imgs/head_icons/${roleInfo.value.head_photo || 1002}.webp`;
});